package cn.lumora.enums;

import java.util.Arrays;


public enum RegisterTypeEnum {
    PASSWORD(0, "passwordRegisterStrategy"),
    SMS_CODE(1, "smsCodeRegisterStrategy");

    private final int code;
    private final String beanName;

    RegisterTypeEnum(int code, String beanName) {
        this.code = code;
        this.beanName = beanName;
    }

    public static String getBeanNameByCode(int code) {
        return Arrays.stream(values())
                .filter(type -> type.code == code)
                .findFirst()
                .map(RegisterTypeEnum::getBeanName)
                .orElseThrow(() -> new IllegalArgumentException("不支持的注册类型: " + code));
    }

    public int getCode() {
        return code;
    }

    public String getBeanName() {
        return beanName;
    }
}
